import React from 'react';
import UserSVG from "../User";
import MarketSVG from "../Market";
import ChangjingSVG from "../Changjing";
import Aircraft from '../Aircraft';


export default class extends React.Component{
    constructor(props){
        super();

        this.state={
            svg:props.svg,
            color:props.color,
            id:props.id
        }
    }

    UNSAFE_componentWillReceiveProps(props){
        this.setState({
            svg:props.svg,
            color:props.color,
            id:props.id
        });
    }

    render(){
        let svgData="";
        switch(this.state.svg){
            case "user":
                svgData=<UserSVG id={this.state.id} color={this.state.color}/>;
                break;
            case "market":
                svgData=<MarketSVG id={this.state.id} color={this.state.color}/>;
                break;
            case "changjing":
                svgData=<ChangjingSVG id={this.state.id} color={this.state.color}/>;
                break;
            case "aircraft":
                svgData=<Aircraft id={this.state.id} color={this.state.color}/>;
                break;
            default :
                break;
        }

        return (
        <span style={{marginRight:"0.5rem"}}>{svgData}</span>
        );
    }
}